package com.scut.online_black_market.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.scut.online_black_market.dto.ShoppingGuideResponse;
import com.scut.online_black_market.entity.ShoppingGuide;
import org.apache.ibatis.annotations.Select;

public interface ShoppingGuideMapper extends BaseMapper<ShoppingGuide> {

    //默认列表
    @Select("select product_id,shopping_guide_name,shopping_guide_price," +
            "shopping_guide_picture_location,shopping_guide_description," +
            "nickname,picture_address,shopping_guide.campus from shopping_guide join personal " +
            "where shopping_guide.shopping_guide_buyer_id = personal.student_number " +
            "and shopping_guide_product_status=1 ")
    IPage<ShoppingGuideResponse> selectType1(IPage<?> page);

    //南校列表
    @Select("select product_id,shopping_guide_name,shopping_guide_price," +
            "       shopping_guide_picture_location,shopping_guide_description," +
            "       nickname,picture_address,shopping_guide.campus from shopping_guide join personal" +
            " where shopping_guide.shopping_guide_buyer_id = personal.student_number and" +
            "        shopping_guide_product_status=1 and shopping_guide.campus=\"南校\"")
    IPage<ShoppingGuideResponse> selectType2(IPage<?> page);

    //北校列表
    @Select("select product_id,shopping_guide_name,shopping_guide_price," +
            "       shopping_guide_picture_location,shopping_guide_description," +
            "       nickname,picture_address,shopping_guide.campus from shopping_guide join personal" +
            " where shopping_guide.shopping_guide_buyer_id = personal.student_number and" +
            "        shopping_guide_product_status=1 and shopping_guide.campus=\"北校\"")
    IPage<ShoppingGuideResponse> selectType3(IPage<?> page);

    //价格从小到大
    @Select("select product_id,shopping_guide_name,shopping_guide_price," +
            "       shopping_guide_picture_location,shopping_guide_description," +
            "       nickname,picture_address,shopping_guide.campus from shopping_guide join personal" +
            " where shopping_guide.shopping_guide_buyer_id = personal.student_number and" +
            " shopping_guide_product_status=1 order by shopping_guide.shopping_guide_price ")
    IPage<ShoppingGuideResponse> selectType4(IPage<?> page);

    //价格从大到小
    @Select("select product_id,shopping_guide_name,shopping_guide_price," +
            "       shopping_guide_picture_location,shopping_guide_description," +
            "       nickname,picture_address,shopping_guide.campus from shopping_guide join personal" +
            " where shopping_guide.shopping_guide_buyer_id = personal.student_number and" +
            " shopping_guide_product_status=1 order by shopping_guide.shopping_guide_price DESC")
    IPage<ShoppingGuideResponse> selectType5(IPage<?> page);
}
